﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SWS.PIP.CMD
{
	public enum FilterColor
	{
		Undefine = 0,
		Green = 1 << 0, 
		Yellow = 1 << 1,
		Orange = 1 << 2,
		AntiqueWhite = 1 << 3,
		Blue = 1 << 4,
		LightBlue = 1 << 5,
		Red = 1 << 6,
		Cyan = 1 << 7,
	}

	public partial class ColorPanelForm : Form
	{
		public event EventHandler<EventArgs> FilteColor;

		public ColorPanelForm()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (checkBox1.CheckState == CheckState.Checked)
				checkBox1.CheckState = CheckState.Unchecked;
			else
				checkBox1.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button3_Click(object sender, EventArgs e)
		{
			if (checkBox2.CheckState == CheckState.Checked)
				checkBox2.CheckState = CheckState.Unchecked;
			else
				checkBox2.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button4_Click(object sender, EventArgs e)
		{
			if (checkBox3.CheckState == CheckState.Checked)
				checkBox3.CheckState = CheckState.Unchecked;
			else
				checkBox3.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button2_Click(object sender, EventArgs e)
		{
			if (checkBox4.CheckState == CheckState.Checked)
				checkBox4.CheckState = CheckState.Unchecked;
			else
				checkBox4.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button5_Click(object sender, EventArgs e)
		{
			if (checkBox5.CheckState == CheckState.Checked)
				checkBox5.CheckState = CheckState.Unchecked;
			else
				checkBox5.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button6_Click(object sender, EventArgs e)
		{
			if (checkBox6.CheckState == CheckState.Checked)
				checkBox6.CheckState = CheckState.Unchecked;
			else
				checkBox6.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button7_Click(object sender, EventArgs e)
		{
			if (checkBox7.CheckState == CheckState.Checked)
				checkBox7.CheckState = CheckState.Unchecked;
			else
				checkBox7.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		private void button8_Click(object sender, EventArgs e)
		{
			if (checkBox8.CheckState == CheckState.Checked)
				checkBox8.CheckState = CheckState.Unchecked;
			else
				checkBox8.CheckState = CheckState.Checked;

			if (FilteColor != null)
				FilteColor(this, new EventArgs());
		}

		internal FilterColor GetFilterColor()
		{
			FilterColor filteColor = 0;

			if (checkBox1.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Green;

			if (checkBox2.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Yellow;

			if (checkBox3.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Orange;

			if (checkBox4.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.AntiqueWhite;

			if (checkBox5.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Blue;

			if (checkBox6.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.LightBlue;

			if (checkBox7.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Red;

			if (checkBox8.CheckState == CheckState.Checked)
				filteColor = filteColor | FilterColor.Cyan;

			return filteColor;
		}


	}
}
